package com.kim.common.utilcom.constants;

/**
 * 请求结果
 */
public enum CodeEnum {

    /**
     * 请求成功
     */
    SUCCESS("200", "请求成功"),

    /**
     * 请求失败
     */
    ERROR("500", "请求失败"),

    /**
     * 请求超时
     */
    REQUEST_TIMED_OUT_ERROR("502", "请求超时"),

    /**
     * 系统错误请求失败
     */
    SYS_ERROR("9999", "系统错误，请求失败"),

    /**
     * XSS攻击
     */
    XSS("503", "请求拦截，请稍后再试"),


    ;

    private final String retCode;

    private final String retMsg;

    CodeEnum(String retCode, String retMsg) {
        this.retCode = retCode;
        this.retMsg = retMsg;
    }

    public String getRetCode() {
        return retCode;
    }

    public String getRetMsg() {
        return retMsg;
    }

    public static String getRetMsg(String retCode) {
        CodeEnum[] responseConstants = values();
        for (CodeEnum ret : responseConstants) {
            if (ret.getRetCode().equals(retCode)) {
                return ret.getRetMsg();
            }
        }
        return "";
    }
}
